package whf.framework.log.events;

import org.hibernate.event.PostLoadEvent;
import org.hibernate.event.PostLoadEventListener;
import org.hibernate.event.def.DefaultPostLoadEventListener;

import whf.framework.entity.Entity;
import whf.framework.log.env.Environment;
import whf.framework.log.util.LogConfig;

/**
 * @author king
 * @create 2008-1-21 下午06:03:59
 * 
 */
@SuppressWarnings("serial")
public class HibernatePostLoadEventListener extends DefaultPostLoadEventListener implements PostLoadEventListener {
	
	
	/* (non-Javadoc)
	 * @see org.hibernate.event.def.DefaultPostLoadEventListener#onPostLoad(org.hibernate.event.PostLoadEvent)
	 */
	@Override
	public void onPostLoad(PostLoadEvent event) {
		super.onPostLoad(event);
		Entity entity = (Entity)event.getEntity();
		if(LogConfig.isHistoriable(entity.getClass())) {
			Environment.set((Entity)entity);
		}
	}

}
